 {block name="body"}
<link rel="shortcut icon" href="favicon.ico">
<link href="__CSS__/bootstrap.min.css" rel="stylesheet">
<link href="__CSS__/font-awesome.min.css" rel="stylesheet">
<link href="__CSS__/animate.min.css" rel="stylesheet">
<link href="__CSS__/style.min.css" rel="stylesheet">
<link href="__CSS__/admin.css" rel="stylesheet">
<div class="ibox float-e-margins">
	<div class="ibox-content form-horizontal">
		<div class="form-group">
		<div class="col-sm-4 col-sm-offset-8" style="text-align: right;">
				<button class="btn btn-info"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;
				<span onclick="wclose()"><a class="btn btn-danger"><i class="fa fa-arrow-left"></i> 返回 </a></span>
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-3 control-label">限时：</label>
			<div class="input-group col-sm-4">
				<div class="onoffswitch">
					<input name="limit1" id="limit1" type="checkbox" {if $msgood.limit1}checked{/if} class="onoffswitch-checkbox" >
					<label class="onoffswitch-label" for="limit1">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
				</div>
			</div>
		</div>
		<div class="form-group limit1" {if $msgood.limit1 == 0}style="display:none"{/if}>
			<label class="col-sm-3 control-label">每天开始销售时间 </label>
			<div class="input-group col-sm-4">
				<input type="text" name="start_time" id="start_time" onclick="WdatePicker({dateFmt:'HH:mm:00'})" class="form-control" value="{$msgood.start_time}" />
			</div>
		</div>
		<div class="form-group limit1" {if $msgood.limit1 == 0 }style="display:none"{/if}>
			<label class="col-sm-3 control-label">每天结束销售时间 </label>
			<div class="input-group col-sm-4">
				<input type="text" name="end_time" id="end_time" onclick="WdatePicker({dateFmt:'HH:mm:00'})" class="form-control" value="{$msgood.end_time}" />
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-3 control-label">限量：</label>
			<div class="input-group col-sm-4">
				<div class="onoffswitch">
					<input name="limit2" id="limit2" type="checkbox" {if $msgood.limit2}checked{/if} class="onoffswitch-checkbox">
					<label class="onoffswitch-label" for="limit2">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
				</div>
			</div>
		</div>
		<div class="form-group limit2" {if $msgood.limit2 == 0}style="display:none"{/if}>
			<label class="col-sm-3 control-label">每天最多销售商品件数 </label>
			<div class="input-group col-sm-4">
				<input type="text" name="sale_num" id="sale_num" class="form-control" value="{$msgood.sale_num}" />
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-3 control-label">限购：</label>
			<div class="input-group col-sm-4">
				<div class="onoffswitch">
					<input name="limit3" id="limit3" type="checkbox" {if $msgood.limit3}checked{/if} class="onoffswitch-checkbox">
					<label class="onoffswitch-label" for="limit3">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
				</div>
			</div>
		</div>
		<div class="form-group limit3" {if $msgood.limit3 == 0}style="display:none"{/if}>
			<label class="col-sm-3 control-label">每人限购件数 </label>
			<div class="input-group col-sm-4">
				<input type="text" name="people_num" id="people_num" class="form-control" value="{$msgood.people_num}" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">状态：</label>
			<div class="input-group col-sm-4" id="ms_status">
			<input type="radio" name="is_ms" id="is_ms" value="0" {if $msgood.is_ms==0} {php echo checked="true"} {/if}/> 关闭
			&nbsp;
			<input type="radio" name="is_ms" id="is_ms" value="1" {if $msgood.is_ms==1} {php echo checked="true"} {/if}/> 开启
			</div>
		</div>
		 <!--基本信息end-->
		<div class="hr-line-dashed"></div>
	</div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.min.js"></script>
<script src="__JS__/bootstrap.min.js"></script>
<script src="__JS__/jquery.metisMenu.js"></script>
<script src="__JS__/jquery.slimscroll.min.js"></script>
<script src="__LIB__/layer/layer.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>
	function wclose(){
    	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
        parent.layer.close(index);  
	}
	
	$(".btn-info").click(function(){
    	var ms_name = $("#ms_name").val();
    	var id = '{$id}';
    	$.ajax({
            type:"POST",
            url:"savems",
			data:{id:id,is_ms:$('#ms_status input[name="is_ms"]:checked').val()
			,limit1:$('input[name="limit1"]:checked').val(),limit2:$('input[name="limit2"]:checked').val(),limit3:$('input[name="limit3"]:checked').val(),start_time:$("#start_time").val(),end_time:$("#end_time").val()
			,sale_num:$("#sale_num").val(),people_num:$("#people_num").val()},
            success:function(data){
				layer.msg(data.msg, {
				  icon: 1,
				  time: 1000 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					if(data.code == 200) {
						parent.layer.closeAll();
   						parent.window.location.reload();
   					}
				}); 
            }
		});		
    });
    
	$("input[name='limit1']").click(function(){
		var value = document.getElementById("limit1").checked;
		if(value == true){
			$(".limit1").show();
		}else if(value == false){
			$(".limit1").hide();
		}
	})
	$("input[name='limit2']").click(function(){
		var value = document.getElementById("limit2").checked;
		if(value == true){
			$(".limit2").show();
		}else if(value == false){
			$(".limit2").hide();
		}
	})
	$("input[name='limit3']").click(function(){
		var value = document.getElementById("limit3").checked;
		if(value == true){
			$(".limit3").show();
		}else if(value == false){
			$(".limit3").hide();
		}
	})
</script>
{/block}